# @Time : 2021/2/19 22:57
# @Author : Li Kunlun
# @Description : vstack测试
import numpy as np
import pandas as pd
import plotly.graph_objects as go

a = np.floor(10 * np.random.random((2, 2)))
b = np.floor(10 * np.random.random((2, 2)))
# print(np.vstack((a, b)))
print(np.vstack([a, b]))


def f(x):
    f1 = np.sum(x);  # Equation (3.1)
    f2 = np.prod(x);  # Equation (3.2)
    return np.array([f1, f2])


print("----------------------------------")
objective_values = np.empty((0, 2))
# print(objective_values)
# print(objective_values.shape)
for i in range(50):
    x = np.random.rand(8)
    y = f(x)
    objective_values = np.vstack([objective_values, y])
    print("objective_values---", objective_values)

objective_values = pd.DataFrame(objective_values, columns=['f1', 'f2'])
print(objective_values)

fig = go.Figure()
fig.add_scatter(x=objective_values.f1, y=objective_values.f2, mode='markers')
fig.show()
